<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>
<body>
    <div id="app">
        <com-a></com-a>
    </div>
    <template id="coma">
        <h1>我是coma组件</h1>
    </template>
    <script>
        // 离线存储 
        // localStorage ，在vue里没有层级划分 
        let ComA = {
            template:"#coma",
            data:function(){
                return {
                    message:"数据",
                    obj:{
                        name:"张三",
                        age:20
                    }
                }
            },
            mounted(){
                // localStorage.setItem("message",this.obj); 
                localStorage.setItem("message",JSON.stringify(this.obj));
            }
        }



        new Vue({
            el:"#app",
            components:{
                ComA
            },
            mounted:function(){
               let m =  JSON.parse( localStorage.getItem("message")) ;
               console.log(m); 
            }
        })


    </script>
</body>
</html>